home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Sound / Amster / Source / lamp.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-11  |  2.7 KB  |  131 lines

  1. /*
  2. ** Amster - Lamp
  3. ** Copyright © 1999-2000 by Gürer Özen
  4. **
  5. ** This program is free software; you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation; either version 2 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program; if not, write to the Free Software
  17. ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18. */
  19.  
  20. #include "amster.h"
  21.  
  22. #include <MUI/Lamp_mcc.h>
  23. #include <MUI/TWFmultiLED_mcc.h>
  24. #include <MUI/NListview_mcc.h>
  25.  
  26. struct TWFmultiLED_RGB lamp_cols[] = {
  27.     { 0xffffffff, 0x00000000, 0x00000000 },
  28.     { 0x00000000, 0xffffffff, 0x00000000 },
  29.     { 0xffffffff, 0xffffffff, 0x00000000 },
  30.     { 0x00000000, 0x00000000, 0x00000000 },
  31. };
  32.  
  33. u_long *lamp_objs[] = { NULL, NULL, NULL, NULL };
  34.  
  35. #define LAMP_RED 0
  36. #define LAMP_GREEN 1
  37. #define LAMP_YELLOW 2
  38. #define LAMP_BLACK 3
  39.  
  40. int lamp_lamp(void);
  41. int lamp_twf(void);
  42.  
  43.  
  44. int lamp_create(void)
  45. {
  46.     if (prf->lamps==0) {
  47.         if(lamp_lamp()) return(1);
  48.         if(lamp_twf()) return(1);
  49.     }
  50.     else {
  51.         if(lamp_twf()) return(1);
  52.         if(lamp_lamp()) return(1);
  53.     }
  54.     return(0);
  55. }
  56.  
  57.  
  58. void lamp_dispose(void)
  59. {
  60.     int i;
  61.  
  62.     for (i=0; i<4; i++) {
  63.         if(lamp_objs[i]) MUI_DisposeObject(lamp_objs[i]);
  64.         lamp_objs[i] = NULL;
  65.     }
  66. }
  67.  
  68.  
  69. int lamp_lamp(void)
  70. {
  71.     int i, e=0;
  72.  
  73.     for (i=0; i<4; i++) {
  74.         lamp_objs[i] = LampObject,
  75.             MUIA_Lamp_Type, MUIV_Lamp_Type_Big,
  76.             MUIA_Lamp_Red, lamp_cols[i].Red,
  77.             MUIA_Lamp_Green, lamp_cols[i].Green,
  78.             MUIA_Lamp_Blue, lamp_cols[i].Blue,
  79.         End;
  80.         if (!lamp_objs[i]) e++;
  81.     }
  82.     if (!e) return(1);
  83.     lamp_dispose();
  84.     return(0);
  85. }
  86.  
  87.  
  88. int lamp_twf(void)
  89. {
  90.     int i, e=0;
  91.  
  92.     for (i=0;i<4;i++) {
  93.         lamp_objs[i] = TWFmultiLEDObject,
  94.             MUIA_TWFmultiLED_Colour, MUIV_TWFmultiLED_Colour_Custom,
  95.             MUIA_TWFmultiLED_Custom, &lamp_cols[i],
  96.         End;
  97.         if (!lamp_objs[i]) e++;
  98.     }
  99.     if (!e) return(1);
  100.     lamp_dispose();
  101.     return(0);
  102. }
  103.  
  104.  
  105. void lamp_useinlist(u_long *list)
  106. {
  107.     if (!lamp_objs[LAMP_RED]) return;
  108.     DoMethod(list, MUIM_NList_UseImage, lamp_objs[LAMP_BLACK ], 1, 0);
  109.     DoMethod(list, MUIM_NList_UseImage, lamp_objs[LAMP_RED   ], 2, 0);
  110.     DoMethod(list, MUIM_NList_UseImage, lamp_objs[LAMP_YELLOW], 3, 0);
  111.     DoMethod(list, MUIM_NList_UseImage, lamp_objs[LAMP_GREEN ], 4, 0);
  112. }
  113.  
  114.  
  115. char *lamp_getforlist(int i)
  116. {
  117.     static char *objs[] = {
  118.         "\33c\33o[1]",
  119.         "\33c\33o[2]",
  120.         "\33c\33o[3]",
  121.         "\33c\33o[4]",
  122.         "\33c?",
  123.         "\33c!",
  124.         "\33c!!",
  125.         "\33c!!!"
  126.     };
  127.  
  128.     if (lamp_objs[LAMP_RED]) return(objs[i]);
  129.     return(objs[i+4]);
  130. }
  131.